package org.ihelpuoo.weboo.action.http.db;

import org.ihelpuoo.orm.filter.FieldFilter;
import org.ihelpuoo.weboo.action.http.AjaxAction;
import org.ihelpuoo.weboo.module.ActionContext;

/**
 * <b>SaveBeanAction class:</b>
 * <hr color=grey size=1>
 *
 * This action will save one bean to database. The bean type is required.
 * It defined in action properties named "bean"
 * 
 * If the action failed, HTTP 500 will be returned.
 *
 * @author zozoh  created @ 2007
 *
 */
public class SaveAction extends AjaxAction
{

	@Override
	protected Object doAjax(ActionContext context) throws Exception
	{
		return save(context,context.getFormObject(),context.properties()
				.getDBIOActivedFieldFilter(),context.properties().getDBIOLockedFieldFilter());
	}

	protected Object save(ActionContext context, Object obj, FieldFilter actived, FieldFilter locked)
			throws Exception
	{
		return context.pojo().save(obj,actived,locked);
	}
}
